//
//  LFFoodDetailController.m
//  LoveFruit
//
//  Created by 张令林 on 16/9/24.
//  Copyright © 2016年 张令林. All rights reserved.
//

#import "LFFoodDetailController.h"
#import "LFSellerDetailCell.h"

static NSString *sellerDetailCell = @"sellerDetailCell";
static NSString *sellerDetailImgCell = @"sellerDetailImgCell";

@interface LFFoodDetailController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,weak) UITableView *tableView;

@end

@implementation LFFoodDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //调用初始化方法
    [self setUpUI];
}

#pragma mark 初始化方法
- (void)setUpUI
{
    self.view.backgroundColor = [UIColor orangeColor];
    self.title = self.sellerModel.name;
    UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview:tableView];
    self.tableView = tableView;
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.showsVerticalScrollIndicator = NO;
    //设置组高度和组头高度
//    tableView.rowHeight = 222;
    tableView.estimatedRowHeight = 220;
    tableView.rowHeight = UITableViewAutomaticDimension;
    //注册单元格
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:sellerDetailImgCell];
    [self.tableView registerNib:[UINib nibWithNibName:@"LFSellerDetailCell" bundle:nil] forCellReuseIdentifier:sellerDetailCell];
    
    //添加一个下面的购物车视图
    
    
}


#pragma mark - 数据源方法
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    self.navigationController.navigationBar.alpha = 1;
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.section == 0)
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:sellerDetailImgCell forIndexPath:indexPath];
        UIImageView *imageView = [[UIImageView alloc] init];
        NSURL *url = [NSURL URLWithString:self.sellerModel.img];
        [imageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"001"]];
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        tableView.rowHeight = 450;
        imageView.size = CGSizeMake(self.view.width, 400);
        imageView.center = imageView.center;
        [cell.contentView addSubview:imageView];
        return cell;
        
    }else if (indexPath.section == 1)
    {
        LFSellerDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:sellerDetailCell forIndexPath:indexPath];
        tableView.rowHeight = 222;
        return cell;
    }else
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:sellerDetailImgCell forIndexPath:indexPath];
        UIImageView *imageView = [[UIImageView alloc] init];
        NSURL *url = [NSURL URLWithString:self.sellerModel.img];
        [imageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"author"]];
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        tableView.rowHeight = 800;
        imageView.size = CGSizeMake(self.view.width, 400);
        imageView.center = imageView.center;
        [cell.contentView addSubview:imageView];
        return cell;
    }
    
}




@end
